<?php
session_start();
require_once( 'path.php' );
require_once( SOJ_ROOT.'/include/function/lib.php' );

//得到用户名,查询用户是否存在
@$request = $_GET ;
@$username = $request['username'];
$db = db_connect();

try {

	$db_obj_user = new db_obj_user( $db ) ;

	if ( $db_obj_user->load( 'username' , $username ) ) {

		$db_obj_user_profile = new db_obj_user_profile( $db );

		if ( $db_obj_user_profile->load( 'username' , $username )){
					
			$username = $db_obj_user->get('username') ;
			$email = $db_obj_user->get('email') ;
			$last_signin_time = $db_obj_user->get('last_signin_time');
			$signup_time = $db_obj_user->get('signup_time');
			
			$nick = $db_obj_user_profile->get('nick');
			$sex = $db_obj_user_profile->get('sex');
			$location = $db_obj_user_profile->get('location');
			$motto = $db_obj_user_profile->get('motto');			
		}
	}

$tpl = new my_smarty();

//若用户已经登录,则重定向到首页
//@todo 之后可以改进为用户之前的页面
if( !empty($_SESSION['username']) ){

	$tpl->assign( 'username' , $_SESSION['username'] );
}
//处理由do_singin.php页面保存在会话中的错误信息
if( !empty($_SESSION['errors']) ){

	$tpl->assign( 'errors' , $_SESSION['errors']  );
	//清除之前的错误信息
	$_SESSION['errors'] = array();
}

$tpl->assign( 'username' , $username ) ;
$tpl->assign( 'email' , $email );
$tpl->assign( 'signup_time' , $signup_time );
$tpl->assign( 'last_signin_time' , $last_signin_time );
$tpl->assign( 'nick' , $nick );
$tpl->assign( 'sex' , $sex );
$tpl->assign( 'location' , $location );
$tpl->assign( 'motto' , $motto ) ;

$tpl->display('user_information.tpl');

}catch( Exception $e ){

	exception_handle( $e ) ;	
}


